package Redis

import (
	"fmt"
	"github.com/go-redis/redis/v8"
	"log"
	"time"
)

var (
	Client *redis.Client
)

func init() {
	Client = redis.NewClient(&redis.Options{
		Addr:         "47.115.225.243:6379",
		Password:     "redis@2003",
		DB:           0,
		DialTimeout:  5 * time.Second,
		MinIdleConns: 4,
		MaxConnAge:   2 * time.Minute,
	})
	_, err := Client.Ping(Client.Context()).Result()
	if err != nil {
		panic(fmt.Sprintf("redis初始化失败:%s", err.Error()))
	}
	log.Println("Redis初始化完成")
}

func GetClient() *redis.Client {
	return Client
}
